﻿using UnityEngine;
using System.Collections;

public class LoadingScene : MonoBehaviour {
   
    public static void TestInit() 
    {
        // 게임 시작점
        Constants.InitConstants();
        //SceneController.Create();
        //SoundController.Create();
        AssetBundleManager.Create();
        UserData.Create();
        PopupManager.Create();

        ResourceManager.Inst.PatchDataFile(() =>
        {
            GameData.Init();
            //TextData.Init();
            EventData.Init();
            CashData.Init();
            //UserData.Instance.m_Language = Language.text_ko;
        });
    }

	void Awake()
    {
        Screen.sleepTimeout = SleepTimeout.NeverSleep;

        //Debug.Log(Screen.width + " / " + Screen.height);
        //Screen.SetResolution(Screen.width, Screen.width * 9 / 16, true);    // 강제 9대 16

        // 게임 시작점
        Constants.InitConstants();
        //SceneController.Create();
        //SoundController.Create();
        AssetBundleManager.Create();
        UserData.Create();
        PopupManager.Create();

        //NetworkManager.Instance.C2S_LOGIN(AuthPlatformID.None, "uniqleee2123", "123123", LoginSuccess, LoginSuccess);

        //ResourceManager.Inst.PatchDataFile(() =>
        //{
        //    Debug.Log(Application.persistentDataPath);
        //    GameData.Init();
        //    //TextData.Init();
        //    EventData.Init();
        //    CashData.Init();
        //    Localization.language = UserData.Instance.m_Language.ToString();
        //    SceneController.LoadLevel("Login");
        //});
        
        //NetworkManager.Instance.C2S_USER_JOIN(AuthPlatformID.None, "uniqleee2123", "123123", "3123", 1, "222222", ResponseModel);
    }

    void ResponseModel(ResponseModel<UserModel> a)
    {
        Debug.Log(a.data);
    }

    void LoginSuccess(ResponseModel<UserModel> a)
    {
        Debug.Log(a.data);
        Debug.Log(a.data.account);
        Debug.Log(GameData.Inst.startChar[0].name);

    }

    void LoginFail(ResponseModel<UserModel> a)
    {
        Debug.Log(a.data);
        Debug.Log(a.data.account);
    }


    IEnumerator Start()
    {
        yield return StartCoroutine(ResourceManager.Inst.PatchDataFile(null, () => { }));
        Debug.Log(Application.persistentDataPath);
        GameData.Init();
        //TextData.Init();
        EventData.Init();
        CashData.Init();     
        SceneController.LoadLevel("Login");
    }
}
